public class Dog {
    public String name;
    public int age;
    public String color;

    //构造方法(名字必须与类名相同） 无返回值
   /* public Dog(){
        System.out.println("不带参数的构造方法");
        this.name="大黄";
        this.age=9;
        this.color="黄色";
    }*/

    public Dog(){
        //调用当前类中其他的构造方法，调用带有3个参数的构造方法
        this("大黄",9,"黄色");
        System.out.println("不带参数的构造方法");
    }

   /* public Dog(){
        //调用当前类中其他的构造方法，调用带有3个参数的构造方法
        System.out.println("不带参数的构造方法");
        this("大黄",9,"黄色");//顺序不能改变，this小括号在第一行
    }*/

    //快速生成
    public Dog(String name, String color) {
        this.name = name;
        this.color = color;
    }

    public Dog(String name, int age, String color) {
        //this(); this之间的调用不能形成环
        this.name = name;
        this.age = age;
        this.color = color;
        System.out.println("Dog(String name, int age, String color)");
    }

    /* public Dog(String name,int age,String color){
        this.name=name;
        this.age=age;
        this.color=color;
    }*/

    public void eat(){
        System.out.println(name+"正在吃狗粮");
    }
    public void sleep(){
        System.out.println(name+"正在睡觉");
    }
    public void show(){
        System.out.println("姓名："+name+" 年龄:"+age+" 颜色："+color);
    }

    public static void main(String[] args) {
        Dog dog=new Dog();
        //成员变量在未初始化之前都有默认值
        dog.show();

        /*Dog dog1=new Dog("小飞",10,"黑色");
        dog1.show();*/
    }

    public static void main1(String[] args) {
        Dog dog=new Dog();//实际上 调用构造方法
        dog.name="小黄";
        dog.age=10;
        dog.color="黄色";
        dog.eat();
        dog.sleep();
        dog.show();
    }

}

